package com.wangyi.im.request;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils;

public class IMMessageRequest {

    private String from;

    private Integer ope;

    private String to;

    private Integer type;

    private JSONObject body;

    private String antispam;

    private String antispamCustom;

    private String option;

    private String pushcontent;

    private String payload;

    private String ext;

    private Integer msgSenderNoSense;

    private String deleteMsgid;

    private Long timetag;

    private IMMessageRequest(String from, int ope, String to, int type, JSONObject body){
        this.from = from;
        this.ope = ope;
        this.to = to;
        this.type = type;
        this.body = body;
    }

    public static class Builder{
        private String from;
        private int ope;
        private String to;
        private int type;
        private String msg;
        private JSONObject jsonMsg;

        public IMMessageRequest build(){
            if(msg != null && jsonMsg == null){
                jsonMsg = new JSONObject();
                jsonMsg.put("msg", msg);
            }
            return new IMMessageRequest(from, ope, to, type, jsonMsg);
        }

        public Builder setFrom(String from) {
            this.from = from;
            return this;
        }

        public Builder setOpe(int ope) {
            this.ope = ope;
            return this;
        }

        public Builder setTo(String to) {
            this.to = to;
            return this;
        }

        public Builder setType(int type) {
            this.type = type;
            return this;
        }

        public Builder setMsg(String msg) {
            this.msg = msg;
            return this;
        }

        public Builder setJsonMsg(JSONObject jsonMsg) {
            this.jsonMsg = jsonMsg;
            return this;
        }
    }
}
